import React from 'react'
// import store from '../../store/store'
import { getMovieList } from '../../store/slice/movieSlice'

import { useDispatch, useSelector } from 'react-redux'

export default function Movie() {
  const dispatch = useDispatch()

  const getMovielistHandle = () => {
    dispatch(getMovieList())
  }

  const count = useSelector(state => state.count.count)
  const movieList = useSelector(state => state.movie.movieList)
  // const { count } = store.getState().count
  // const { movieList } = store.getState().movie
  // console.log(movieList,'movieList');

  return (
    <div>
      <h1>我是Movie组件</h1>
      <p>我收到的Count组件的值是 {count}</p>
      <button onClick={getMovielistHandle}>获取电影的数据</button>
      {
        movieList.map(item => {
          return <li key={item.tvId}>{item.name}</li>
        })
      }
    </div>
  )
}
